package com.acyouzi.leetcode.math;

import java.util.Arrays;

/**
 * Created by SUN on 2017/10/11.
 */
public class MinimumMoves {
  public int minMoves2(int[] nums) {
    Arrays.sort(nums);
    int res = 0;
    int start = 0;
    int end = nums.length-1;
    while (start < end){
      res += nums[end--] - nums[start++];
    }
    return res;
  }
}
